//
//  ExamineTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/23.
//

#import "ExamineTableViewCell.h"
@interface ExamineTableViewCell ()

@property (nonatomic ,strong) UILabel * taskName;
@property (nonatomic ,strong) UILabel * applyTypeLab;
@property (nonatomic ,strong) UILabel * statusName;
@property (nonatomic ,strong) UILabel * pondName;
@property (nonatomic ,strong) UILabel * executeTime;

///申请进度
@property (nonatomic ,strong) UIView * sqjdview;

@property (nonatomic ,strong) UILabel * handover;
@property (nonatomic ,strong) UILabel * leftuserName;
@property (nonatomic ,strong) UIView * lineview;
@property (nonatomic ,strong) UIView * userNameview;

@property (nonatomic ,strong) UILabel * userName;
@property (nonatomic ,strong) UILabel * createTime;
@property (nonatomic ,strong) UILabel * lefthandover;

@end
@implementation ExamineTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    self.contentView.clipsToBounds = YES;
    
    
    UIView * backview = [UIView new];
    [self.contentView addSubview:backview];
    backview.backgroundColor = UIColor.whiteColor;
    [DTKTool YJ:kwt(5) andView:backview];
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.offset(0);
        make.bottom.offset(kwt(-10));
    }];
    
    
    UILabel * statusName = [DTKTool labelWithText:@"--" andFont:kCFont(15) andTextColor:UIColor.whiteColor];
    self.statusName= statusName;
    statusName.textAlignment = NSTextAlignmentCenter;
    [backview addSubview:statusName];
    [statusName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-12));
        make.top.offset(kwt(12));
    }];
    
    
    UILabel * taskName = [DTKTool labelWithText:@"--" andFont:kCFont(18) andTextColor:KcolorHex(@"#0967FF")];
    self.taskName= taskName;
    [backview addSubview:taskName];
    [taskName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.top.offset(kwt(15));
    }];
    
    UILabel * applyTypeLab = [DTKTool labelWithText:@"--" andFont:kFont(14) andTextColor:KcolorHex(@"#7B7B7B")];
    self.applyTypeLab= applyTypeLab;
    [DTKTool YJBK:kwt(3) andView:applyTypeLab andWidth:0.5 andColor:KcolorHex(@"#8D8D8D")];
    applyTypeLab.textAlignment = NSTextAlignmentCenter;
    [backview addSubview:applyTypeLab];
    [applyTypeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(taskName.mas_right).offset(kwt(5));
        make.centerY.equalTo(taskName);
        make.width.offset(kwt(40));
        make.height.offset(kwt(19));

    }];
    
    UILabel * pondName = [DTKTool labelWithText:@"--" andFont:kCFont(16) andTextColor:KcolorHex(@"#222222")];
    self.pondName = pondName;
//    pondName.numberOfLines = 0;
    [backview addSubview:pondName];
    [pondName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(350));
        make.left.offset(kwt(12));
        make.top.offset(kwt(46));
        make.height.offset(kwt(16));
    }];
    
    
    UILabel * templab = [DTKTool labelWithText:@"执行时间：" andFont:kFont(15) andTextColor:KcolorHex(@"#787A79")];
    [backview addSubview:templab];
    [templab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.height.offset(kwt(15));
        make.top.equalTo(pondName.mas_bottom).offset(kwt(12));
    }];
    
    UILabel * executeTime = [DTKTool labelWithText:@"--" andFont:kFont(15) andTextColor:KcolorHex(@"#222222")];
    self.executeTime= executeTime;
    [backview addSubview:executeTime];
    [executeTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(templab.mas_right);
        make.centerY.equalTo(templab);
    }];
    
    UIView * sqjdview = [UIView new];
    self.sqjdview = sqjdview;
    sqjdview.backgroundColor = KcolorHex(@"#F6F6F6");
    [DTKTool YJ:kwt(3) andView:sqjdview];
    [backview addSubview:sqjdview];

    [sqjdview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.right.bottom.offset(kwt(-12));
        make.top.equalTo(templab.mas_bottom).offset(kwt(10));
    }];
    
    UIView * zjview = [UIView new];
    zjview.backgroundColor = KcolorHex(@"#FF8800");
    [DTKTool YJ:kwt(4) andView:zjview];
    [sqjdview addSubview:zjview];
    [zjview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.width.height.offset(kwt(8));
        make.top.offset(kwt(11));
    }];
    UILabel * zjleftlab = [DTKTool labelWithText:@"转交人：" andFont:kFont(15) andTextColor:KcolorHex(@"#787A79")];
    self.leftuserName = zjleftlab;
    [sqjdview addSubview:zjleftlab];
    [zjleftlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(35));
        make.centerY.equalTo(zjview);
    }];
    
    
    UILabel * userName = [DTKTool labelWithText:@"--" andFont:kFont(15) andTextColor:KcolorHex(@"#222222")];
    self.userName= userName;
    [sqjdview addSubview:userName];
    [userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(zjleftlab.mas_right);
        make.centerY.equalTo(zjleftlab);
    }];
    
    UIView * userNameview = [UIView new];
    userNameview.backgroundColor = KcolorHex(@"#02BD4B");
    self.userNameview = userNameview;
    [DTKTool YJ:kwt(4) andView:userNameview];
    [sqjdview addSubview:userNameview];
    [userNameview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.width.height.offset(kwt(8));
        make.top.offset(kwt(38));
    }];
    
    UIView * lineview = [UIView new];
    self.lineview = lineview;
    lineview.backgroundColor = KcolorHex(@"#CECECE");
    [sqjdview addSubview:lineview];
    [lineview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(zjview);
        make.width.offset(1);
        make.top.equalTo(zjview.mas_bottom);
        make.bottom.equalTo(userNameview.mas_top);
    }];
    
    UILabel * sqleftlab = [DTKTool labelWithText:@"接收人：" andFont:kFont(15) andTextColor:KcolorHex(@"#787A79")];
    self.lefthandover = sqleftlab;
    [sqjdview addSubview:sqleftlab];
    [sqleftlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(35));
        make.centerY.equalTo(userNameview);
    }];
    
    UILabel * handover = [DTKTool labelWithText:@"--" andFont:kFont(15) andTextColor:KcolorHex(@"#222222")];
    self.handover= handover;
    [sqjdview addSubview:handover];
    [handover mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(sqleftlab.mas_right);
        make.centerY.equalTo(sqleftlab);
    }];
    
    UILabel * sqsjlab = [DTKTool labelWithText:@"申请时间：" andFont:kFont(15) andTextColor:KcolorHex(@"#787A79")];
    [sqjdview addSubview:sqsjlab];
    [sqsjlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(kwt(-7));
        make.left.offset(kwt(12));
    }];
    
    UILabel * createTime = [DTKTool labelWithText:@"--" andFont:kFont(15) andTextColor:KcolorHex(@"#222222")];
    self.createTime= createTime;
    [sqjdview addSubview:createTime];
    [createTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(sqsjlab.mas_right);
        make.centerY.equalTo(sqsjlab);
    }];
}

- (void)setModel:(ExamineModel *)model{
    _model = model;
    self.taskName.text = model.taskName;
    self.statusName.text = model.statusName;
    self.statusName.textColor = KcolorHex(model.statusColor);
    ///审核类型;1:取消 2:转交
    self.applyTypeLab.text = (model.applyType == 2)?@"转交":@"取消";
    self.leftuserName.text = (model.applyType == 2)?@"转交人：":@"申请人：";
    self.lineview.hidden = self.handover.hidden = self.lefthandover.hidden = self.userNameview.hidden = (model.applyType == 1);

//    self.pondName.text = [NSString stringWithFormat:@"%@ %@",model.pondTissue,model.pondName];
//    [self.pondName mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.height.offset(model.pondNameH);
//    }];
    NSArray * pondStrArray = [model.tissueListStr componentsSeparatedByString:@"\n"];
//    if (pondStrArray.count > 1){
//        self.pondName.text = [NSString stringWithFormat:@"%@...",pondStrArray.firstObject];
//
//    } else {
        self.pondName.text = pondStrArray.firstObject;

//    }
//    self.pondName.text = model.tissueListStr;
//    [self.pondName mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.height.offset(model.tissueListStrH);
//    }];
    self.executeTime.text = model.executeTime;
    self.createTime.text = model.createTime;
    self.userName.text = model.userName;
    self.handover.text = model.handover;
    
}
@end
